from django.contrib import admin
from .models import ImageGeneration


@admin.register(ImageGeneration)
class ImageGenerationAdmin(admin.ModelAdmin):
    list_display = ['prompt', 'user', 'style', 'status', 'width', 'height', 'created_at']
    list_filter = ['status', 'style', 'created_at']
    search_fields = ['prompt', 'user__username']
    readonly_fields = ['created_at', 'updated_at']
    
    def prompt(self, obj):
        return obj.prompt[:50] + '...' if len(obj.prompt) > 50 else obj.prompt
    prompt.short_description = '提示词'
